package com.example.config;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * 后置处理器
 * 每一个对象初始化方法调用前后执行的回调
 * spring 底层的注入等功能都是BeanPostProcessor实现
 */
public class MyBeanPostProcessor implements BeanPostProcessor {
    /**
     * 后
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName)
            throws BeansException {
        System.out.println("postProcessAfterInitialization"+" - "+beanName+" - "+bean);
        return bean;
    }

    /**
     * 前
     */
    public Object postProcessBeforeInitialization(Object bean, String beanName)
            throws BeansException {
        System.out.println("postProcessBeforeInitialization"+" - "+beanName+" - "+bean);
        return bean;
    }
}



